<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp" %>
<html>
<head>
    <meta charset="utf-8"/>
    <title>数据字典明细</title>
</head>
<body>
<%@include file="../../../include/lr.jsp" %>
<div class="lr-form-wrap" id="form">
    <input id="F_ParentId" type="hidden"/>
    <div class="col-xs-12 lr-form-item">
        <div class="lr-form-item-title">项目名<font face="宋体">*</font></div>
        <input id="F_ItemName" type="text" class="form-control" placeholder="请输入名称" isvalid="yes"
               checkexpession="NotNull"/>
    </div>
    <div class="col-xs-12 lr-form-item">
        <div class="lr-form-item-title">项目值<font face="宋体">*</font></div>
        <input id="F_ItemValue" type="text" class="form-control" placeholder="请输入编号" isvalid="yes"
               checkexpession="NotNull"/>
    </div>
    <div class="col-xs-12 lr-form-item">
        <div class="lr-form-item-title">排序<font face="宋体">*</font></div>
        <input id="F_SortCode" type="text" class="form-control" placeholder="请输入排序号" isvalid="yes"
               checkexpession="Num"/>
    </div>
    <div class="col-xs-12 lr-form-item">
        <div class="checkbox">
            <label>
                <input id="F_EnabledMark" type="checkbox" checked="checked"/>
                有效
            </label>
        </div>
    </div>
    <div class="col-xs-12 lr-form-item">
        <div class="lr-form-item-title">备注</div>
        <textarea id="F_Description" class="form-control" style="height: 90px;"></textarea>
    </div>
</div>
<script>

    var parentId = request('parentId');
    var itemCode = request('itemCode');
    var keyValue = request('keyValue');
    var acceptClick;
    var selectedRow = top.selectedDataItemRow;

    var page = {
        init: function () {
            page.bind();
            page.initData();
        },
        bind: function () {
            /*检测重复项*/
            $('#F_ItemName').on('blur', function () {
                $.lrExistField(keyValue, 'F_ItemName','${ctx}/sys/DataItem/ExistDetailItemName', { itemCode: itemCode });
            });
            $('#F_ItemValue').on('blur', function () {
                $.lrExistField(keyValue, 'F_ItemValue', '${ctx}/sys/DataItem/ExistDetailItemValue', { itemCode: itemCode });
            });
        },
        initData: function () {
            if (!!selectedRow) {
                keyValue = selectedRow.F_ItemDetailId || '';
                $('#form').lrSetFormData(selectedRow);
            }
            else {
                $('#F_ParentId').val(parentId);
            }
        }
    };
    // 保存数据
    acceptClick = function (callBack) {
        if (!$('#form').lrValidform()) {
            return false;
        }
        var postData = $('#form').lrGetFormData(keyValue);

        $.lrSaveForm('${ctx}/sys/DataItem/SaveDetailForm?keyValue=' + keyValue + "&itemCode="+itemCode, postData, function (res) {
            // 保存成功后才回调
            if (!!callBack) {
                callBack();
            }
        });
    };

    page.init();
</script>
</body>
</html>
